package com.egao.gps.quartz.sample;

import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

/**
 * @author : Doman
 * @version ：1.0
 * @date : 2020-02-03 23:47
 */
public class HelloScheduleDemo {
    public static void main(String[] args) throws SchedulerException {
        // 1.调度器
        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();

        // 2.任务实例
        JobDetail jobDetail = JobBuilder.newJob(HelloJob.class)
                .withIdentity("job1", "group1")
                .build();

        //3.触发器
        Trigger trigger = (Trigger) TriggerBuilder.newTrigger()
                .withIdentity("trigger1", "group1")
                .startNow()
                .withSchedule(SimpleScheduleBuilder.simpleSchedule()
                        .withIntervalInMilliseconds(5000).repeatForever())
                .build();

        scheduler.scheduleJob(jobDetail, trigger);
        scheduler.start();
    }
}
